package com.zhang.springbootdemo.controller;

import com.zhang.springbootdemo.dto.TestStudentDto;
import com.zhang.springbootdemo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @ClassName TestStudentController
 * @Description 测试springboot功能的一个单独controller
 * @Author zhanghongguo
 * @Date 2021/12/27 17:09
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
public class TestStudentController {
    @Autowired
    private StudentService studentService;
    @PostMapping("getStudents")
    public Object getStudents(@RequestBody TestStudentDto testStudentDto){
        List<Map> students = studentService.getStudents(testStudentDto);
        return students;
    }
    @GetMapping("getStudents")
    public Object getStudentsByGet(
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "tId",required = false) String tId){
        List<Map> students = studentService.getStudentsByGet(name,tId);
        return students;
    }
}
